<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <title>摩比秀</title>
    <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="full-screen" content="true"/>
    <meta name="screen-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="360-fullscreen" content="true"/>
    <meta name="format-detection" content="telephone=no">
    <!--不进行缓存-->
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
    <META HTTP-EQUIV="Expires" CONTENT="0"> 
    <link rel="icon" type="image/png" href="uploads/imgs/favicon.png">
    <style>
        html, body {  background: #e8ebd0; overflow:hidden;  padding: 0;  border: 0; margin: 0;  height: 100%;}
        #adPage{ position: fixed; width:100%; height:100%; left:0; top:0; right:0; background: rgba(0,0,0,0.7); z-index: 1001}
        #adImgBox{ position: absolute; width:600px; left:50%; margin-left: -300px; height:400px; top:50%; margin-top:-200px; }
        #imgBoxLink{width:100%; height:400px; display: block; background-size:contain; background-repeat: no-repeat;}
        #adImgBox img{ width:100%;}
        #closeAd{ position: absolute; z-index: 2;right:-40px; top:0; margin-top:-40px; width:36px; height:36px; background: url(uploads/imgs/close.png) no-repeat; background-size: 100% 100%;}
        #loadIframe{ position: fixed; z-index: 2001; left: 0; top:0; right:0; bottom:0; background:url(uploads/imgs/loading.gif) center center no-repeat #fff;  background-size: 32px 32px;}
        .loadIframe-top{ color:#fff; background: #333; height:60px; line-height: 60px; box-sizing: border-box; padding:0 10px; position: relative; overflow: hidden;}
        #loadIframeClose{ background: url(uploads/imgs/back.png) left center no-repeat; position: absolute; padding-left: 35px; left:10px; top:0; cursor: pointer;}
        #loadIframeClose:active{opacity: 0.5}
        .loadIframe-top h2{ text-align: center; font-size:16px; padding:0; margin:0;}
        .loadIframe-box{ width:100%;height:90vh;-webkit-overflow-scrolling: touch;overflow-y: scroll; }
        .loadIframe-box iframe{ width:100%; border: none;}
        .loadIframeIn{
            -webkit-animation:fadeInUp 0.5s 0s ease both;
            -moz-animation:fadeInUp 0.5s 0s ease both;
            animation:fadeInUp 0.5s 0s ease both;
        }
        @-webkit-keyframes fadeInUp{
                0%{opacity:.8;-webkit-transform:translateY(1000px)}
                100%{opacity:1;-webkit-transform:translateY(0)}
                }
        @keyframes fadeInUp{
                0%{opacity:.8;transform:translateY(1000px)}
                100%{opacity:1;transform:translateY(0)}
        }
        .loadIframeOut{
            -webkit-animation:fadeOutDown 0.5s 0s ease both;
            -moz-animation:fadeOutDown 0.5s 0s ease both;
            animation:fadeOutDown 0.5s 0s ease both;
        }
        @-webkit-keyframes fadeOutDown{
            0%{-webkit-transform:translateY(0)}
            100%{opacity:0;-webkit-transform:translateY(1000px)}
        }
        @keyframes fadeOutDown{
                0%{opacity:1;transform:translateY(0)}
                100%{opacity:0;transform:translateY(1000px)}
            }
        @media screen and (orientation:portrait){
            #adImgBox{ transform: rotate(90deg)}
        }
        @media screen and (max-width:760px){
            #adImgBox{width:300px; height:200px;margin-left: -150px; margin-top:-100px;}
            #closeAd{ right:-25px; margin-top:-25px; width:18px; height:18px;} 
        }
    </style>
</head>

<body>
    <div style="margin: auto;width: 100%;height: 100%;" class="egret-player"
         data-entry-class="Main"
         data-orientation="landscapeFlipped"
         data-scale-mode="fixedWidth"
         data-frame-rate="30"
         data-content-width="1024"
         data-content-height="768"
         data-multi-fingered="2"
         data-show-fps="false" data-show-log="false"
         data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
    </div>
    <div id="indexMsg"><div style=" width: 100%; height: 100%; position: fixed; left:0; top:0; display: flex; display: -webkit-flex; align-items: center; flex-wrap: wrap; justify-content: center; font-size:30px; z-index: 2000; background: #e8ebd0;">
        <div style="flex-grow: 1; text-align: center;"><img src="uploads/imgs/unhappy.png" /><div style="height:100px; width: 100%;text-align:center;line-height: 60px; opacity: 0.6;" id="indexMsgText">获取用户身份出错~</div></div>
    <script>
        var version = 2018090405;  //app版本，资源缓存更新

        var query_uid = GetQueryString("uid");
        var query_area = GetQueryString("area");
        var query_key = GetQueryString("key");
        var query_scene = GetQueryString("scene");

        //地址栏有值
        if(query_uid && query_key && query_area){
            var userInfo = {
                uid:query_uid,
                area:query_area,
                key:query_key
            }
            getUserSuccess();
            try{
                window.sessionStorage.setItem("userInfo", JSON.stringify(userInfo));
            }catch(e){}
        }else{
            //无值 试着从storage中取
            try{
                var _userInfo = window.sessionStorage.getItem("userInfo");
                if(_userInfo){
                    var userInfo = JSON.parse(_userInfo);
                    query_uid = userInfo.uid;
                    query_area = userInfo.area;
                    query_key = userInfo.key;
                    getUserSuccess();
                }else{
                    getUserInfoError()
                }
            }catch(e){
                getUserInfoError()
            }
        }
        
        function getUserInfoError(){
            setInfoError("获取用户身份出错~");
        }
        //获取用户信息成功
         
        function getUserSuccess(){
            var indexMsg = document.getElementById("indexMsg");
            indexMsg.style.display = "none";
            initGame();
        }

        function setInfoError(msg){
            var indexMsg = document.getElementById("indexMsg");
            document.getElementById("indexMsgText").innerHTML = msg;
            indexMsg.style.display = "block";
        }


        var loadScript = function (list, callback) {
            var loaded = 0;
            var loadNext = function () {
                loadSingleScript(list[loaded], function () {
                    loaded++;
                    if (loaded >= list.length) {
                        callback();
                    }
                    else {
                        loadNext();
                    }
                })
            };
            loadNext();
        };

        var loadSingleScript = function (src, callback) {
            var s = document.createElement('script');
            s.async = false;
            s.src = src;
            s.addEventListener('load', function () {
                s.parentNode.removeChild(s);
                s.removeEventListener('load', arguments.callee, false);
                callback();
            }, false);
            document.body.appendChild(s);
        };

        function initGame(){
            var xhr = new XMLHttpRequest();
            xhr.open('GET', './manifest.json?v=' + Math.random(), true);
            xhr.addEventListener("load", function () {
                var manifest = JSON.parse(xhr.response);
                var list = manifest.initial.concat(manifest.game);
                list.unshift("uploads/config.js");
                if(isRequireUpdate){
                    for(var i in list){
                        list[i] = list[i]+"?v"+version;
                    }
                }
                loadScript(list, function () {
                    /**
                     * {
                     * "renderMode":, //Engine rendering mode, "canvas" or "webgl"
                     * "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
                     * "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
                     * "calculateCanvasScaleFactor": //a function return canvas scale factor
                     * }
                     **/
                    egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
                        var backingStore = context.backingStorePixelRatio ||
                            context.webkitBackingStorePixelRatio ||
                            context.mozBackingStorePixelRatio ||
                            context.msBackingStorePixelRatio ||
                            context.oBackingStorePixelRatio ||
                            context.backingStorePixelRatio || 1;
                        return (window.devicePixelRatio || 1) / backingStore;
                    }});
                });
            });
            xhr.send(null);
        }

        //是否需要更新
        var isRequireUpdate = function(){
            try{
                var v = window.localStorage.getItem("v");
                if(v != version){
                    window.localStorage.setItem("v",version);
                    return true;
                }else{
                    return false;
                }
            }catch(e){
                return true;
            }
        }();

        //获取地址栏参数
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        } 

    </script>
    <div class="version" style="display: none">App-Mini v3.4.0 20180904
        <!--统计-->
        <div style="display: none">
            <script src="https://s4.cnzz.com/z_stat.php?id=1261165430&web_id=1261165430" language="JavaScript"></script>
            <script>
                var _czc = _czc || [];
            </script>
        </div>
    </div>
</body>
</html>